<!--装货员端装货记录-->
/* eslint-disable */
<template>
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/index' }">装货员端</el-breadcrumb-item>
    <el-breadcrumb-item>装配历史</el-breadcrumb-item>
  </el-breadcrumb>

  <div class="card_search">
    <div class="add-btn">
<!--      <el-button @click="dialogVisible = true">一键打印所有订单</el-button>-->
      <el-select v-model="orderTime" class="m-2" placeholder="请选择截单日期" size="large" clearable>
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
        />
      </el-select>
    </div>
    <div class="add-btn">
      <el-button @click="printAllOrder('xlsx')">一键打印所有订单</el-button>
      <el-button @click="printOrder('xlsx')">一键打印库存总单</el-button>
    </div>
<!--    <div class="search_date">-->
<!--      <el-date-picker-->
<!--          v-model="dateRange"-->
<!--          type="daterange"-->
<!--          unlink-panels-->
<!--          range-separator="至"-->
<!--          start-placeholder="开始日期"-->
<!--          end-placeholder="结束日期"-->
<!--          :shortcuts="shortcuts"-->
<!--          size="large"-->
<!--      />-->
<!--    </div>-->
 <div class="add-btn">
<!--      <el-button @click="dialogVisible = true">一键打印所有订单</el-button>-->
      <el-select v-model="queryInfo.status" @change="selectChange" 
	  class="m-2" placeholder="请选择订单状态" size="large" clearable>
        <el-option
            v-for="item in statusOP"
            :key="item.value"
            :label="item.label"
            :value="item.value"
        />
      </el-select>
    </div>
    <el-input
        v-model="queryInfo.cardNum"
        class="search"
        size="large"
        placeholder="Search..."
        @blur="getOrderInfo"
		@keyup.enter='getOrderInfo'
    />
    <img src="@/assets/imgs/home/search.png" alt="" @click="getOrderInfo" style="width: 0.4rem; background-color: rgb(57,62,74); cursor: pointer;">
  </div>
  <el-form>
    <el-table
        ref="warRef"
        :data="warList"
        :header-cell-style = "headerStyle"
        :cell-style = "cellStyle"
        class="table"
        @selection-change="handleSelectionChange"
    >
	
<!--      <el-table-column type="selection"/>-->
      <el-table-column key="expand" type="expand" min-width="4%">
        <template #default="props">
<!--          <div class="good_list">-->
<!--            <dl v-for="item in props.row.detailedEntities" :key="item.id">-->
<!--              <dt><img :src="item.images" alt="good"></dt>-->
<!--              <dd>{{item.dishesName}}</dd>-->

<!--            </dl>-->
<!--          </div>-->
          <div v-if="props.row.vegetableList.length">
            <div class="divSon">蔬菜类</div>
            <el-table
                :data="props.row.vegetableList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.meetList.length">
            <div class="divSon">肉类</div>
            <el-table
                :data="props.row.meetList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.eggList.length">
            <div class="divSon">蛋类</div>
            <el-table
                :data="props.row.eggList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.fishList.length">
            <div class="divSon">水产类</div>
            <el-table
                :data="props.row.fishList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.bestList.length">
            <div class="divSon">特产类</div>
            <el-table
                :data="props.row.bestList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.riceList.length">
            <div class="divSon">大米类</div>
            <el-table
                :data="props.row.riceList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.cornList.length">
            <div class="divSon">玉米类</div>
            <el-table
                :data="props.row.cornList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.fruitList.length">
            <div class="divSon">水果类</div>
            <el-table
                :data="props.row.fruitList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName"  min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity"  min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.birdList.length">
            <div class="divSon">禽类</div>
            <el-table
                :data="props.row.birdList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.meetliveList.length">
            <div class="divSon">畜肉类</div>
            <el-table
                :data="props.row.meetliveList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
          <div v-if="props.row.freeList.length">
            <div class="divSon">赠品类</div>
            <el-table
                :data="props.row.freeList"
                :header-cell-style = "headerStyleSon"
                :cell-style = "cellStyleSon"
                class="tableSon"
            >
              <el-table-column property="dishesName" min-width="2%"></el-table-column>
              <el-table-column property="purchaseQuantity" min-width="2%"></el-table-column>
            </el-table>
          </div>
        </template>
      </el-table-column >
      <el-table-column key="single" label="订单号" show-overflow-tooltip min-width="10%">
     <template #default="scope">
	 <div @click="copy(scope.row.single)">{{ scope.row.single }}</div>
	 </template>
	  </el-table-column>
	  <el-table-column key="cardAccount" label="卡号" min-width="10%">
		  <template #default="scope">
		  <div @click="copy(scope.row.cardAccount)">{{ scope.row.cardAccount }}</div>
		  </template>
	  </el-table-column>
	  <el-table-column key="cardType" label="卡类" min-width="15%">
	  <template #default="scope">
	  <div @click="copy(scope.row.cardType)">{{ scope.row.cardType }}</div>
	  </template>
	  </el-table-column>
	  <el-table-column key="userName" label="昵称" min-width="10%">
	 <template #default="scope">
	 <div @click="copy(scope.row.userName)">{{ scope.row.userName }}</div>
	 </template>
	  </el-table-column>
<!--      <el-table-column property="userName" label="昵称" />-->
      <el-table-column key="telephone"  label="手机号" show-overflow-tooltip min-width="12%">
     <template #default="scope">
	 <div @click="copy(scope.row.telephone)">{{ scope.row.telephone }}</div>
	 </template>
	  </el-table-column>
      <el-table-column key="address" label="地址" show-overflow-tooltip min-width="20%">
      <template #default="scope" >
		<div @click="copy(scope.row.address)">{{ scope.row.address }}</div> 
	  </template>
	  </el-table-column>
      <el-table-column key="deliveryTime" label="送达时间" min-width="10%">
        <template #default="scope">
		<div @click="copy(scope.row.deliveryTime)">{{ scope.row.deliveryTime }}</div> 
		</template>
      </el-table-column>
	  <el-table-column key="remark" label="备注" min-width="15%">
		  <template #default="scope">
		  <div @click="copy(scope.row.remark)">{{ scope.row.remark }}</div>
		  </template>
	  </el-table-column>
      <el-table-column key="status" label="订单状态" min-width="10%">
		  <template #default="scope">{{ scope.row.status }}</template>
      </el-table-column>
      <el-table-column key="Download" label="操作" min-width="25%">
        <template #default="scope">
          <!--打印按钮-->
		   <!-- <el-button type="primary"  title="删除订单" :icon="Delete" size='large' @click='deleteOrder(scope.row.id)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button> -->
		  
          <el-button type="primary"  title="打印订单" :icon="Download" size='large' @click='printThisOrder("pdf", scope.row.id, scope.row.single)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button>
          <el-button type="primary"  title="添加物流信息" :icon="AddLocation" size='large' @click='addLogistics(scope.row.id)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button>
          <el-button type="primary"  v-if="scope.row.remark!='系统默认下单'||scope.row.status=='已装配'" title="查看物流信息" :icon="Van" size='large' @click='getLogistics(scope.row.id)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button>
		   <el-button type="primary" v-if="scope.row.status=='待装配'&&scope.row.remark=='系统默认下单'"  title="取消订单" :icon="CloseBold" size='large' @click='deleteOrder(scope.row.single)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-form>

  <el-pagination
      @current-change="handleCurrentChange"
      background
      layout="prev, pager, next"
      :total="total"
      :current-page="queryInfo.currentPage"
      :page-size="queryInfo.pageSize"
      class="pagination-container"
  />

  <!--  添加物流-->
  <el-dialog
      title="添加物流(无则不填，多个则用减号-分割)"
      :model-value="dialogVisibleAdd"
      :close-on-click-modal="false"
      width="50%" @close='closeAdd'>
    <div class="sub_form">
      <div class="item_form">
        <p>顺丰单号:</p><el-input v-model='addForm.logistics[0].single'></el-input>
      </div>
      <div class="item_form">
        <p>中通单号:</p><el-input v-model='addForm.logistics[1].single'></el-input>
      </div>
      <div class="item_form">
        <p>京东单号:</p><el-input v-model='addForm.logistics[2].single'></el-input>
      </div>
      <div class="item_form">
        <p>邮政单号:</p><el-input v-model='addForm.logistics[3].single'></el-input>
      </div>
      <div class="item_form">
        <p>自送单号:</p>
		<!-- <el-input v-model='addForm.logistics[4].single'></el-input> -->
		<el-select v-model="addForm.logistics[4].single" class="m-2" placeholder="请选择自送or无需物流" size="large" clearable>
		  <el-option label="自送" value="自送" />
			<el-option label="无需物流" value="无需物流" />
		</el-select>
      </div>
    </div>

      <div class='item_button'>
        <span class="dialog-footer">
          <el-button @click="dialogVisibleAdd = false">取 消</el-button>
          <el-button type="primary" @click="addThisLogistics">确 定</el-button>
        </span>
      </div>
  </el-dialog>

  <!--  查看物流-->
  <el-dialog
      title="查看物流信息"
      :model-value="dialogVisibleGet"
      :close-on-click-modal="false"
      width="50%" @close='closeGet'>
    <el-table
        ref="warRef"
        :data="wlList"
        :header-cell-style = "headerStyle"
        :cell-style = "cellStyle"
        class="table"
        @selection-change="handleSelectionChange"
    >
      <el-table-column property="logisticsName" label="物流方式" min-width="15%"/>
      <el-table-column property="single" label="物流单号" show-overflow-tooltip min-width="15%"/>
      <el-table-column label="操作" min-width="25%">
        <template #default="scope">
          <el-button type="primary" :icon="EditPen" size='large' @click='changeLogistics(scope.row.id)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button>
          <el-button type="primary" :icon="Delete" size='large' @click='deleteLogistics(scope.row.id)' style="border: 1px solid white; background-color: rgb(57,62,74)"></el-button>
        </template>
      </el-table-column>
    </el-table>
      <div class='item_button'>
        <span class="dialog-footer">
          <el-button @click="dialogVisibleGet = false">确 定</el-button>
        </span>
      </div>
  </el-dialog>

  <!--  修改物流-->
  <el-dialog
      title="修改物流"
      :model-value="dialogVisibleCg"
      :close-on-click-modal="false"
      width="50%" @close='closeCg'>
    <el-form label-width='70px' :model='cgForm'>
      <el-form-item prop='name' label="物流厂家">
        <el-select v-model="cgForm.name" class="m-2" placeholder="Select">
          <el-option
              v-for="item in wlStyle"
              :key="item"
              :label="item"
              :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item prop='single' label='物流单号'>
        <el-input v-model='cgForm.single'></el-input>
      </el-form-item>
      <div class='item_button'>
        <span class="dialog-footer">
          <el-button @click="dialogVisibleCg = false">取 消</el-button>
          <el-button type="primary" @click="cgLogistics">确 定</el-button>
        </span>
      </div>
    </el-form>
  </el-dialog>
  <!--  取消订单-->
  <el-dialog
      :model-value="dialogVisibleDelete"
      :close-on-click-modal="false"
	  style="margin-top: 3rem;"
      width="30%" @close='dialogVisibleDelete=false'
	  >
   <div style="height: 0.4rem;font-size: 0.2rem;">
   	<el-icon style="color: red;line-height: 0.4rem;"><WarningFilled /></el-icon>
	<span>此操作不可取消，是否确定删除此订单！</span>
   </div>
      <div class='item_button'>
			<el-button @click="dialogVisibleDelete = false">取 消</el-button>
          <el-button @click="deleteDialog" style="margin-left: 1rem;">确 定</el-button>
      </div>
  </el-dialog>
</template>

<script setup>
import {reactive, ref, getCurrentInstance, onMounted} from "vue";
import {useRouter} from "vue-router";
import { ElNotification } from 'element-plus'
import {
  Download, AddLocation, Van, EditPen, Delete,WarningFilled,CloseBold
} from '@element-plus/icons-vue'
import {changeGo, getDetailGo} from "@/service/WarehouseService";
const {proxy} = getCurrentInstance()
// 渲染
const total = ref(0)
const statusOP=[
	{value:"已装配",label:"已装配"},
	{value:"待装配",label:"待装配"},
]
const queryInfo = reactive({
  status: '装配',
  currentPage: 1,
  pageSize: 8,

})
const router = useRouter()
let order = reactive([])
// 所有总单提交时间
const options = reactive([])
const orderTime = ref('')
// dateRange
const dateRange = ref('')
const shortcuts = [
  {
    text: '过去一周',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      return [start, end]
    },
  },
  {
    text: '过去一个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      return [start, end]
    },
  }
]
// 装配完成的订单
const warList = reactive([])

// 当前点击物流订单id
const orderId = ref(0)
const wlStyle = [
    '顺丰', '中通', '京东', '邮政', '基地自送'
]
// 添加物流
const dialogVisibleAdd = ref(false)
const addRef = ref('')
let addForm = reactive({
  oid: 0,
  logistics: [
    {name: '顺丰', single: ''},
    {name: '中通', single: ''},
    {name: '京东', single: ''},
    {name: '邮政', single: ''},
    {name: '基地自送', single: ''}
  ]
})
// 查看物流
const dialogVisibleGet = ref(false)
const wlList = reactive([])
//修改物流
const dialogVisibleCg = ref(false)
const thisSingle = ref('')
let cgForm = reactive({})

// 渲染
onMounted(() => {
  getBuyOrder()
  getAllOrderTime()
})

// 复制
const copy=(context)=>{
	// 创建输入框元素
	            let oInput = document.createElement('input');
	            // 将想要复制的值
	            oInput.value = context;
	            // 页面底部追加输入框
	            document.body.appendChild(oInput);
	            // 选中输入框
	            oInput.select();
	            // 执行浏览器复制命令
	            document.execCommand('Copy');
	            // 弹出复制成功信息
	           ElNotification.success({
	               title: 'Success',
	               message: '复制成功',
	               offset: 100,
	             })
	            // 复制后移除输入框
	            oInput.remove();

}
// 修改el-table默认样式
const headerStyle = () => {
  return {
    'font-size':'20px',
    'color': 'black',
    'text-align': 'center'
  }
}

const cellStyle = () => {
  return {
    'background-color':'rgb(57,62,74)',
    'color': 'white',
    'text-align': 'center'
  }
}

const headerStyleSon = () => {
  return {
    'font-size':'16px',
    'color': 'black',
    'text-align': 'center',
    'margin-top': '-50px !important'
  }
}

const cellStyleSon = () => {
  return {
    'background-color':'rgb(0,152,131)',
    'color': 'white',
    'text-align': 'center'
  }
}

// table选择变化
const handleSelectionChange = val => {
  order = val
}

// 获取所有status为已截单的订单
const getBuyOrder = async () => {
	// console.log(queryInfo);
  const {data: res} = await proxy.$http.WarehouseService.getOrder(queryInfo)
  if (res.code !== 200) return proxy.$message.error('获取已下单订单数据失败')
  warList.length = 0
  // console.log(res)
  for (let i= 0; i< res.data.records.length; i++) {
    res.data.records[i].vegetableList=[]
    res.data.records[i].meetList=[]
    res.data.records[i].eggList=[]
    res.data.records[i].fishList=[]
    res.data.records[i].bestList=[]
    res.data.records[i].riceList=[]
    res.data.records[i].cornList=[]
    res.data.records[i].fruitList=[]
    res.data.records[i].birdList=[]
    res.data.records[i].meetliveList=[]
    res.data.records[i].freeList=[]
    res.data.records[i].deliveryTime = res.data.records[i].deliveryTime.substring(0,10)
    for (let j = 0; j < res.data.records[i].detailedEntities.length; j++) {
      if (res.data.records[i].detailedEntities[j].dishType === '蔬菜') res.data.records[i].vegetableList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '肉') res.data.records[i].meetList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '蛋') res.data.records[i].eggList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '水产') res.data.records[i].fishList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '特产') res.data.records[i].bestList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '大米') res.data.records[i].riceList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '玉米') res.data.records[i].cornList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '水果') res.data.records[i].fruitList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '禽类') res.data.records[i].birdList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '畜肉') res.data.records[i].meetliveList.push(res.data.records[i].detailedEntities[j])
      if (res.data.records[i].detailedEntities[j].dishType === '赠品') res.data.records[i].freeList.push(res.data.records[i].detailedEntities[j])
    }
    warList.push(res.data.records[i])
	
  }
  total.value = res.data.total
}

// 根据分页器切换每页的菜品
const handleCurrentChange = val => {
  queryInfo.currentPage = val
  getBuyOrder()
}
// 搜索
const getOrderInfo = () => {
  getBuyOrder()
}
const selectChange=()=>{
	if(queryInfo.status){
		getBuyOrder()
	}else{
		queryInfo.status="装配"
		getBuyOrder()
	}
	
}
// 获取所有截单日期
const getAllOrderTime = async() => {
  const {data: res} = await proxy.$http.WarehouseService.getOrderTime()
  for (let i = 0; i < res.data.length; i++) {
    res.data[i].assemblyTime = res.data[i].assemblyTime.substring(0,10)
    options.push({value: res.data[i].assemblyTime, label: res.data[i].assemblyTime})
  }
}
// 下载excel
const downloadFile = (res, fileName) => {
  let blob = new Blob([res], { type: 'application/vnd.ms-excel;charset=utf-8' }); //res为从后台返回的数据
  if (!fileName) {
    fileName = orderTime.value + `总单.xlsx`;
  }
  if ('msSaveOrOpenBlob' in navigator) {
    window.navigator.msSaveOrOpenBlob(blob, fileName);
  } else {
    const elink = document.createElement('a');
    elink.download = fileName;
    elink.style.display = 'none';
    elink.href = URL.createObjectURL(blob);
    document.body.appendChild(elink);
    elink.click();
    URL.revokeObjectURL(elink.href);
    document.body.removeChild(elink);
  }
}
// 打印库存总单
const printOrder = ext => {
  if (orderTime.value) {
    proxy.$http.WarehouseService.printTest({'date': orderTime.value}).then(res => {
      const blob = new Blob([res.data])
      const date =
          new Date().getFullYear() +
          "-" +
          (new Date().getMonth() + 1) +
          "-" +
          new Date().getDate()
      const fileName = date + "库存总单." + ext;
      if ("download" in document.createElement("a")) {
        // 非IE下载
        const elink = document.createElement("a");
        elink.download = fileName;
        elink.style.display = "none";
        elink.href = URL.createObjectURL(blob);
        document.body.appendChild(elink);
        elink.click();
        URL.revokeObjectURL(elink.href); // 释放URL 对象
        document.body.removeChild(elink);
      } else {
        // IE10+下载
        navigator.msSaveBlob(blob, fileName);
      }
    })
  }
  else proxy.$message.error('请选择截单日期')
}

// 打印所有订单
const printAllOrder = ext => {
  if (orderTime.value) {
    proxy.$http.WarehouseService.printOrderGo({'date': orderTime.value}).then(res => {
      const blob = new Blob([res.data])
      // const date =
      //     new Date().getFullYear() +
      //     "-" +
      //     (new Date().getMonth() + 1) +
      //     "-" +
      //     new Date().getDate()
      const date = orderTime.value
      const fileName = date + "所有订单." + ext;
      if ("download" in document.createElement("a")) {
        // 非IE下载
        const elink = document.createElement("a");
        elink.download = fileName;
        elink.style.display = "none";
        elink.href = URL.createObjectURL(blob);
        document.body.appendChild(elink);
        elink.click();
        URL.revokeObjectURL(elink.href); // 释放URL 对象
        document.body.removeChild(elink);
      } else {
        // IE10+下载
        navigator.msSaveBlob(blob, fileName);
      }
    })
  }
  else proxy.$message.error('请选择截单日期')
}

// 打印单个订单
const printThisOrder = (ext, oid, orderNum) => {
  proxy.$http.WarehouseService.printOrderDetail({oid}).then(res => {
    window.open(res.data.data)
  })
}

// 添加物流
const closeAdd = () => {
  dialogVisibleAdd.value = false
  addForm.logistics[4].single=''
}
const addLogistics = oid => {
  addForm.oid = oid
  dialogVisibleAdd.value = true
  
}
const rstForm = () => {
  addRef.value.resetFields()
}
const addThisLogistics = async () => {
  const aForm = []
  for(let i = 0; i < 5; i++) {
    if (addForm.logistics[i].single !== '') aForm.push(addForm.logistics[i])
  }
  // console.log(aForm)
  const {data: res} = await proxy.$http.WarehouseService.addGo({oid: addForm.oid, logistics:aForm})
  if (res.code !== 200) proxy.$message.error('添加物流信息失败')
  proxy.$message.success('添加物流信息成功')
  for (let i = 0; i < 5; i++) addForm.logistics[i].single = ''
  getBuyOrder()
  dialogVisibleAdd.value = false
  addForm.logistics[4].single=''
}
// 获取物流
const getLog = async oid => {
  const {data: res} = await proxy.$http.WarehouseService.getGo({eid: oid})
  if (res.code !== 200) proxy.$message.error('查看物流信息失败')
  wlList.length = 0
  for (let i = 0; i < res.data.length; i++) wlList.push(res.data[i])
}

const getLogistics = async oid => {
  dialogVisibleGet.value = true
  orderId.value = oid
  await getLog(oid)
}

const closeGet = () => {
  dialogVisibleGet.value = false
}

// 修改物流
const changeLogistics = async eid => {
  dialogVisibleCg.value = true
  thisSingle.value = eid
  const {data: res} = await proxy.$http.WarehouseService.getDetailGo({eid})
  if (res.code !== 200) return proxy.$message.error('获取详细物流信息失败')
  cgForm.name = res.data.logisticsName
  cgForm.single = res.data.single
}
const closeCg = () => {
  dialogVisibleCg.value = false
}
const cgLogistics = async () => {
  const {data: res} = await proxy.$http.WarehouseService.changeGo({id :thisSingle.value, ...cgForm})
  if (res.code !== 200) return proxy.$message.error('修改物流信息失败')
  await getLog(orderId.value)
  proxy.$message.success('修改物流信息成功')
  dialogVisibleCg.value = false
}

// 删除物流
const deleteLogistics = eid => {
  proxy.$messageBox.confirm('此操作将永久删除该单号, 是否继续?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async () => {
    const {data: res} = await proxy.$http.WarehouseService.deleteGo({eid})
    if (res.code === 200) {
      await getLog(orderId.value)
      return proxy.$message.success('删除菜品成功')
    }
    return proxy.$message.error(res.msg)
  })
      .catch(() => {
        proxy.$message('cancel')
      })
}
const dialogVisibleDelete=ref(false)
const orderIdDialog=ref(0)
// 取消订单
const deleteOrder=(id)=>{
	orderIdDialog.value=id
	console.log(orderIdDialog.value);
	dialogVisibleDelete.value=true
}
// 取消订单确定按钮
const deleteDialog=async ()=>{
	console.log(orderIdDialog.value);
	dialogVisibleDelete.value=false
	const {data: res} = await proxy.$http.WarehouseService.delOrder({oid:orderIdDialog.value})
	if (res.code === 200) {
		getBuyOrder()
	  return proxy.$message.success('取消订单成功')
	}
	return proxy.$message.error(res.msg)
}
</script>

<style scoped lang="scss"> 10000003 1776份 185份
.search{
  width: 25%;
}
.card_search{
  margin-top: 10px;
  display: flex;
  justify-content: right;
}

.add-btn {
  height: 40px;
  display: flex;
  margin-right: 50px;
  .el-button {
    font-size: 0.15rem;
    font-weight: bolder;
    background-color: rgb(0,152,131);
    height: 100%;
    color: white;
  }
  .el-button:hover {
    background-color: white;
    color: rgb(0,152,131);
  }
  .el-input-bg-color {
    background-color: #409EFF;
  }
  :deep(.el-input__inner) {
    // background-color: rgb(0,152,131);
    &::placeholder{
      color: white;
      font-weight: bolder;
      font-size: 16px
    }
  }
  :deep(.el-select .el-input .el-select__caret) {
    color: white;
  }
}

:deep(.search .el-input__wrapper) {
  background-color: rgb(0,152,131)
}

:deep(.add-btn .el-input__wrapper) {
  background-color: rgb(0,152,131)
}

:deep(.search .el-input__inner) {
  color: white
}

.card_search {
  :deep(.el-input__inner) {
    color: white;
    &::placeholder{
      color: white;
      font-size: 16px
    }
  }
}

:deep(.search .el-icon) {
  color: white;
}


.search_date {
  display: flex;
  margin-right: 50px;
}

.table {
  width: 90%;
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  padding-top: 50px;
}
.divSon {
  font-weight: bolder;
  font-size: 20px;
}
.tableSon {

}
:deep(.el-table__body) {
  border-collapse: separate;
  border-spacing: 0 20px;
}
:deep(.el-table__body .el-button){
  border: 1px solid white;
  background-color: rgb(0,152,131);
}
:deep(.el-table__body .el-button:hover){
  color: rgb(0,152,131);
  background-color: white !important;
}
:deep(.el-table__body .el-table__expand-icon){
  color: white;
}

.sub_form {
  .item_form {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    p {
      height: 100%;
      line-height: 35px;
    }
    .el-input {
      width: 80%;
    }
	.el-select{
	  width: 80% !important;
	}
  }
}

.good_list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  dl {
    width: 150px;
    height: 150px;
    padding: 10px 25px;
    box-sizing: border-box;
    margin-left: 26px;
    margin-top: 20px;
    border: 2px solid rgba(75,66,49,0.8);
    dt{
      width: 100px;
      height: 100px;
      img {
        width: 100%;
      }
    }
    dd{
      height: 20px;
      width: 100px;
      margin-top: 10px;
      text-align: center;
    }
  }
}

.el-pagination{
  position: absolute;
  right: 8%;
  bottom: 2%
}

.item_button {
  margin-top: 15px;
}

</style>
